package com.aijk.ehm.sys.api;

import com.aijk.base.entity.PagingRequest;
import com.aijk.commons.exception.ErrorCodeException;
import com.aijk.ehm.sys.service.SysModuleService;
import com.aijk.ehm.sys.model.qo.ModuleQo;
import com.aijk.ehm.sys.model.SysModule;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 模块
 *
 */
@Service("moduleApi")
public class ModuleApiImpl implements ModuleApi {

    private final Logger logger = LoggerFactory.getLogger(ModuleApiImpl.class);


    @Autowired
    private SysModuleService service;

    @Override
    public PageInfo<SysModule> getPage(ModuleQo qo) throws ErrorCodeException {
        PagingRequest pagingRequest = new PagingRequest(qo.getPageNo().intValue(), qo.getPageSize().intValue());
        return service.pageList(pagingRequest,qo);
    }

    @Override
    public SysModule get(Integer id) throws ErrorCodeException {
        return service.findOne(id);
    }

    @Override
    public List<SysModule> get(ModuleQo qo) throws ErrorCodeException {
        return service.find(qo);
    }

    @Override
    public int save(SysModule record) throws ErrorCodeException {
        return service.save(record);
    }

    @Override
    public int updateByPrimary(SysModule record) throws ErrorCodeException {
        return service.update(record);
    }

    @Override
    public int delete(Integer id) throws ErrorCodeException {
        return service.delete(id);
    }
}
